/**
 * @author LiuXu
 * @create 2020-07-03 20:30
 */
package com.cy.pj.goods.dao;

import com.cy.pj.goods.pojo.Goods;
import org.apache.ibatis.annotations.*;

import java.util.List;

/*
 * @Mapper注解由MyBatis框架定义，用于描述数据层接口对象
 * 系统底层启动MyBatis框架会基于该注解的描述，创建该接口实现类，并将实现类对象交给Spring管理
 */

@Mapper
public interface GoodsDao {
    @Insert("INSERT INTO tb_goods (name,remark,createdTime) values (#(name),#(remark),now()))")
    int insertObject(Goods entity);

    /*
     * 基于id删除数据库中的商品信息
     */
    @Delete("DELETE FROM tb_goods WHERE id = #{id}")
    int deleteById(Integer id);

    int deleteObjects(@Param("ids") Integer... ids);

    @Select("SELECT id,name,createdTime FROM tb_goods")
    List<Goods> findObjects();

}
